package com.googlecode.galaxyrise.musiclib.server;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.googlecode.galaxyrise.musiclib.server.dao.AlbumDao;
import com.googlecode.galaxyrise.musiclib.server.dao.TrackDao;
import com.googlecode.galaxyrise.musiclib.server.domain.Album;
import com.googlecode.galaxyrise.musiclib.server.domain.Track;

/**
 * Implementation of the <code>MusicLibrary</code> interface. This is registered
 * in spring context as a transactional service, thus, by default, all
 * unchecked exceptions and errors will result in transaction rollbacks.
 * 
 * @author Igor Jose Topcin <igortopcin@gmail.com>
 */
@Service
@Transactional
public class MusicLibraryImpl implements MusicLibrary {
    
    @Autowired
    private AlbumDao albumDao;
    
    @Autowired
    private TrackDao trackDao;

    public List<Album> getAlbums() {
        return albumDao.getAlbums();
    }

    public List<Track> getAlbumTracks(Long albumId) {
        return trackDao.getAlbumTracks(albumId);
    }

}
